home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir43 / perldoss.zip / PERL.H < prev    next >
C/C++ Source or Header  |  1991-12-19  |  22KB  |  1,077 lines

  1. /* $RCSfile: perl.h,v $$Revision: 4.0.1.5 $$Date: 91/11/11 16:41:07 $
  2.  *
  3.  *    Copyright (c) 1991, Larry Wall
  4.  *
  5.  *    You may distribute under the terms of either the GNU General Public
  6.  *    License or the Artistic License, as specified in the README file.
  7.  *
  8.  * $Log:    perl.h,v $
  9.  * Revision 4.0.1.5  91/11/11  16:41:07  lwall
  10.  * patch19: uts wrongly defines S_ISDIR() et al
  11.  * patch19: too many preprocessors can't expand a macro right in #if
  12.  * patch19: added little-endian pack/unpack options
  13.  *
  14.  * Revision 4.0.1.4  91/11/05  18:06:10  lwall
  15.  * patch11: various portability fixes
  16.  * patch11: added support for dbz
  17.  * patch11: added some support for 64-bit integers
  18.  * patch11: hex() didn't understand leading 0x
  19.  *
  20.  * Revision 4.0.1.3  91/06/10  01:25:10  lwall
  21.  * patch10: certain pattern optimizations were botched
  22.  *
  23.  * Revision 4.0.1.2  91/06/07  11:28:33  lwall
  24.  * patch4: new copyright notice
  25.  * patch4: made some allowances for "semi-standard" C
  26.  * patch4: many, many itty-bitty portability fixes
  27.  *
  28.  * Revision 4.0.1.1  91/04/11  17:49:51  lwall
  29.  * patch1: hopefully straightened out some of the Xenix mess
  30.  *
  31.  * Revision 4.0  91/03/20  01:37:56  lwall
  32.  * 4.0 baseline.
  33.  *
  34.  */
  35.  
  36.  
  37. #define VOIDWANT 1
  38. #include "config.h"
  39.  
  40.  
  41. #ifdef MYMALLOC
  42. #   ifdef HIDEMYMALLOC
  43. #    define malloc Mymalloc
  44. #    define realloc Myremalloc
  45. #    define free Myfree
  46. #   endif
  47. #   define safemalloc malloc
  48. #   define saferealloc realloc
  49. #   define safefree free
  50. #endif
  51.  
  52.  
  53. /* work around some libPW problems */
  54. #define fatal Myfatal
  55. #ifdef DOINIT
  56. char Error[1];
  57. #endif
  58.  
  59.  
  60. #ifdef MSDOS
  61. /* This stuff now in the MS-DOS config.h file. */
  62. #else /* !MSDOS */
  63.  
  64.  
  65. /*
  66.  * The following symbols are defined if your operating system supports
  67.  * functions by that name.  All Unixes I know of support them, thus they
  68.  * are not checked by the configuration script, but are directly defined
  69.  * here.
  70.  */
  71. #define HAS_ALARM
  72. #define HAS_CHOWN
  73. #define HAS_CHROOT
  74. #define HAS_FORK
  75. #define HAS_GETLOGIN
  76. #define HAS_GETPPID
  77. #define HAS_KILL
  78. #define HAS_LINK
  79. #define HAS_PIPE
  80. #define HAS_WAIT
  81. #define HAS_UMASK
  82. /*
  83.  * The following symbols are defined if your operating system supports
  84.  * password and group functions in general.  All Unix systems do.
  85.  */
  86. #define HAS_GROUP
  87. #define HAS_PASSWD
  88.  
  89.  
  90. #endif /* !MSDOS */
  91.  
  92.  
  93. #if defined(__STDC__) || defined(_AIX) || defined(__stdc__)
  94. # define STANDARD_C 1
  95. #endif
  96.  
  97.  
  98. #if defined(HASVOLATILE) || defined(STANDARD_C)
  99. #define VOLATILE volatile
  100. #else
  101. #define VOLATILE
  102. #endif
  103.  
  104.  
  105. #ifdef IAMSUID
  106. #   ifndef TAINT
  107. #    define TAINT
  108. #   endif
  109. #endif
  110.  
  111.  
  112. #ifndef HAS_VFORK
  113. #   define vfork fork
  114. #endif
  115.  
  116.  
  117. #ifdef HAS_GETPGRP2
  118. #   ifndef HAS_GETPGRP
  119. #    define HAS_GETPGRP
  120. #   endif
  121. #   define getpgrp getpgrp2
  122. #endif
  123.  
  124.  
  125. #ifdef HAS_SETPGRP2
  126. #   ifndef HAS_SETPGRP
  127. #    define HAS_SETPGRP
  128. #   endif
  129. #   define setpgrp setpgrp2
  130. #endif
  131.  
  132.  
  133. #include <stdio.h>
  134. #include <ctype.h>
  135. #include <setjmp.h>
  136. #ifndef MSDOS
  137. #ifdef PARAM_NEEDS_TYPES
  138. #include <sys/types.h>
  139. #endif
  140. #include <sys/param.h>
  141. #endif
  142. #ifdef STANDARD_C
  143. /* Use all the "standard" definitions */
  144. #include <stdlib.h>
  145. #include <string.h>
  146. #endif /* STANDARD_C */
  147.  
  148.  
  149. #if defined(HAS_MEMCMP) && defined(mips) && BYTEORDER == 0x1234
  150. #undef HAS_MEMCMP
  151. #endif
  152.  
  153.  
  154. #ifdef HAS_MEMCPY
  155.  
  156.  
  157. #  ifndef STANDARD_C
  158. #    ifndef memcpy
  159. extern char * memcpy(), *memset();
  160. extern int memcmp();
  161. #    endif /* ndef memcpy */
  162. #  endif /* ndef STANDARD_C */
  163.  
  164.  
  165. #   ifndef bcopy
  166. #    define bcopy(s1,s2,l) memcpy(s2,s1,l)
  167. #   endif
  168. #   ifndef bzero
  169. #    define bzero(s,l) memset(s,0,l)
  170. #   endif
  171. #endif /* HAS_MEMCPY */
  172.  
  173.  
  174. #ifndef HAS_BCMP        /* prefer bcmp slightly 'cuz it doesn't order */
  175. #   ifndef bcmp
  176. #    define bcmp(s1,s2,l) memcmp(s1,s2,l)
  177. #   endif
  178. #endif
  179.  
  180.  
  181. #ifndef _TYPES_        /* If types.h defines this it's easy. */
  182. #ifndef major        /* Does everyone's types.h define this? */
  183. #include <sys/types.h>
  184. #endif
  185. #endif
  186.  
  187.  
  188. #ifdef I_NETINET_IN
  189. #include <netinet/in.h>
  190. #endif
  191.  
  192.  
  193. #include <sys/stat.h>
  194. #ifdef uts
  195. #undef S_ISDIR
  196. #undef S_ISCHR
  197. #undef S_ISBLK
  198. #undef S_ISREG
  199. #undef S_ISFIFO
  200. #undef S_ISLNK
  201. #define S_ISDIR(P) (((P)&S_IFMT)==S_IFDIR)
  202. #define S_ISCHR(P) (((P)&S_IFMT)==S_IFCHR)
  203. #define S_ISBLK(P) (((P)&S_IFMT)==S_IFBLK)
  204. #define S_ISREG(P) (((P)&S_IFMT)==S_IFREG)
  205. #define S_ISFIFO(P) (((P)&S_IFMT)==S_IFIFO)
  206. #define S_ISLNK(P) (((P)&S_IFMT)==S_IFLNK)
  207. #endif
  208.  
  209.  
  210. #ifdef I_TIME
  211. #   include <time.h>
  212. #endif
  213.  
  214.  
  215. #ifdef I_SYS_TIME
  216. #   ifdef SYSTIMEKERNEL
  217. #    define KERNEL
  218. #   endif
  219. #   include <sys/time.h>
  220. #   ifdef SYSTIMEKERNEL
  221. #    undef KERNEL
  222. #   endif
  223. #endif
  224.  
  225.  
  226. #ifndef MSDOS
  227. #include <sys/times.h>
  228. #endif
  229.  
  230.  
  231. #if defined(HAS_STRERROR) && (!defined(HAS_MKDIR) || !defined(HAS_RMDIR))
  232. #undef HAS_STRERROR
  233. #endif
  234.  
  235.  
  236. #include <errno.h>
  237. #ifndef MSDOS
  238. #ifndef errno
  239. extern int errno;     /* ANSI allows errno to be an lvalue expr */
  240. #endif
  241. #endif
  242.  
  243.  
  244. #ifndef strerror
  245. #ifdef HAS_STRERROR
  246. char *strerror();
  247. #else
  248. extern int sys_nerr;
  249. extern char *sys_errlist[];
  250. #define strerror(e) ((e) < 0 || (e) >= sys_nerr ? "(unknown)" : sys_errlist[e])
  251. #endif
  252. #endif
  253.  
  254.  
  255. #ifdef I_SYSIOCTL
  256. #ifndef _IOCTL_
  257. #include <sys/ioctl.h>
  258. #endif
  259. #endif
  260.  
  261.  
  262. #if defined(mc300) || defined(mc500) || defined(mc700)    /* MASSCOMP */
  263. #ifdef HAS_SOCKETPAIR
  264. #undef HAS_SOCKETPAIR
  265. #endif
  266. #ifdef HAS_NDBM
  267. #undef HAS_NDBM
  268. #endif
  269. #endif
  270.  
  271.  
  272. #ifdef WANT_DBZ
  273. #include <dbz.h>
  274. #define SOME_DBM
  275. #define dbm_fetch(db,dkey) fetch(dkey)
  276. #define dbm_delete(db,dkey) fatal("dbz doesn't implement delete")
  277. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  278. #define dbm_close(db) dbmclose()
  279. #define dbm_firstkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  280. #define nextkey() (fatal("dbz doesn't implement traversal"),fetch())
  281. #define dbm_nextkey(db) (fatal("dbz doesn't implement traversal"),fetch())
  282. #ifdef HAS_NDBM
  283. #undef HAS_NDBM
  284. #endif
  285. #ifndef HAS_ODBM
  286. #define HAS_ODBM
  287. #endif
  288. #else
  289. #ifdef HAS_GDBM
  290. #ifdef I_GDBM
  291. #include <gdbm.h>
  292. #endif
  293. #define SOME_DBM
  294. #ifdef HAS_NDBM
  295. #undef HAS_NDBM
  296. #endif
  297. #ifdef HAS_ODBM
  298. #undef HAS_ODBM
  299. #endif
  300. #else
  301. #ifdef HAS_NDBM
  302. #include <ndbm.h>
  303. #define SOME_DBM
  304. #ifdef HAS_ODBM
  305. #undef HAS_ODBM
  306. #endif
  307. #else
  308. #ifdef HAS_ODBM
  309. #ifdef NULL
  310. #undef NULL        /* suppress redefinition message */
  311. #endif
  312. #include <dbm.h>
  313. #ifdef NULL
  314. #undef NULL
  315. #endif
  316. #define NULL 0        /* silly thing is, we don't even use this */
  317. #define SOME_DBM
  318. #define dbm_fetch(db,dkey) fetch(dkey)
  319. #define dbm_delete(db,dkey) delete(dkey)
  320. #define dbm_store(db,dkey,dcontent,flags) store(dkey,dcontent)
  321. #define dbm_close(db) dbmclose()
  322. #define dbm_firstkey(db) firstkey()
  323. #endif /* HAS_ODBM */
  324. #endif /* HAS_NDBM */
  325. #endif /* HAS_GDBM */
  326. #endif /* WANT_DBZ */
  327. #ifdef SOME_DBM
  328. EXT char *dbmkey;
  329. EXT int dbmlen;
  330. #endif
  331.  
  332.  
  333. #if INTSIZE == 2
  334. #define htoni htons
  335. #define ntohi ntohs
  336. #else
  337. #define htoni htonl
  338. #define ntohi ntohl
  339. #endif
  340.  
  341.  
  342. #if defined(I_DIRENT)
  343. #   include <dirent.h>
  344. #   define DIRENT dirent
  345. #else
  346. #   ifdef I_SYS_NDIR
  347. #    include <sys/ndir.h>
  348. #    define DIRENT direct
  349. #   else
  350. #    ifdef I_SYS_DIR
  351. #        ifdef hp9000s500
  352. #        include <ndir.h>    /* may be wrong in the future */
  353. #        else
  354. #        include <sys/dir.h>
  355. #        endif
  356. #        define DIRENT direct
  357. #    endif
  358. #   endif
  359. #endif
  360.  
  361.  
  362. #ifdef FPUTS_BOTCH
  363. /* work around botch in SunOS 4.0.1 and 4.0.2 */
  364. #   ifndef fputs
  365. #    define fputs(str,fp) fprintf(fp,"%s",str)
  366. #   endif
  367. #endif
  368.  
  369.  
  370. /*
  371.  * The following gobbledygook brought to you on behalf of __STDC__.
  372.  * (I could just use #ifndef __STDC__, but this is more bulletproof
  373.  * in the face of half-implementations.)
  374.  */
  375.  
  376.  
  377. #ifndef S_IFMT
  378. #   ifdef _S_IFMT
  379. #    define S_IFMT _S_IFMT
  380. #   else
  381. #    define S_IFMT 0170000
  382. #   endif
  383. #endif
  384.  
  385.  
  386. #ifndef S_ISDIR
  387. #   define S_ISDIR(m) ((m & S_IFMT) == S_IFDIR)
  388. #endif
  389.  
  390.  
  391. #ifndef S_ISCHR
  392. #   define S_ISCHR(m) ((m & S_IFMT) == S_IFCHR)
  393. #endif
  394.  
  395.  
  396. #ifndef S_ISBLK
  397. #   ifdef S_IFBLK
  398. #    define S_ISBLK(m) ((m & S_IFMT) == S_IFBLK)
  399. #   else
  400. #    define S_ISBLK(m) (0)
  401. #   endif
  402. #endif
  403.  
  404.  
  405. #ifndef S_ISREG
  406. #   define S_ISREG(m) ((m & S_IFMT) == S_IFREG)
  407. #endif
  408.  
  409.  
  410. #ifndef S_ISFIFO
  411. #   ifdef S_IFIFO
  412. #    define S_ISFIFO(m) ((m & S_IFMT) == S_IFIFO)
  413. #   else
  414. #    define S_ISFIFO(m) (0)
  415. #   endif
  416. #endif
  417.  
  418.  
  419. #ifndef S_ISLNK
  420. #   ifdef _S_ISLNK
  421. #    define S_ISLNK(m) _S_ISLNK(m)
  422. #   else
  423. #    ifdef _S_IFLNK
  424. #        define S_ISLNK(m) ((m & S_IFMT) == _S_IFLNK)
  425. #    else
  426. #        ifdef S_IFLNK
  427. #        define S_ISLNK(m) ((m & S_IFMT) == S_IFLNK)
  428. #        else
  429. #        define S_ISLNK(m) (0)
  430. #        endif
  431. #    endif
  432. #   endif
  433. #endif
  434.  
  435.  
  436. #ifndef S_ISSOCK
  437. #   ifdef _S_ISSOCK
  438. #    define S_ISSOCK(m) _S_ISSOCK(m)
  439. #   else
  440. #    ifdef _S_IFSOCK
  441. #        define S_ISSOCK(m) ((m & S_IFMT) == _S_IFSOCK)
  442. #    else
  443. #        ifdef S_IFSOCK
  444. #        define S_ISSOCK(m) ((m & S_IFMT) == S_IFSOCK)
  445. #        else
  446. #        define S_ISSOCK(m) (0)
  447. #        endif
  448. #    endif
  449. #   endif
  450. #endif
  451.  
  452.  
  453. #ifndef S_IRUSR
  454. #   ifdef S_IREAD
  455. #    define S_IRUSR S_IREAD
  456. #    define S_IWUSR S_IWRITE
  457. #    define S_IXUSR S_IEXEC
  458. #   else
  459. #    define S_IRUSR 0400
  460. #    define S_IWUSR 0200
  461. #    define S_IXUSR 0100
  462. #   endif
  463. #   define S_IRGRP (S_IRUSR>>3)
  464. #   define S_IWGRP (S_IWUSR>>3)
  465. #   define S_IXGRP (S_IXUSR>>3)
  466. #   define S_IROTH (S_IRUSR>>6)
  467. #   define S_IWOTH (S_IWUSR>>6)
  468. #   define S_IXOTH (S_IXUSR>>6)
  469. #endif
  470.  
  471.  
  472. #ifndef S_ISUID
  473. #   define S_ISUID 04000
  474. #endif
  475.  
  476.  
  477. #ifndef S_ISGID
  478. #   define S_ISGID 02000
  479. #endif
  480.  
  481.  
  482. #ifdef f_next
  483. #undef f_next
  484. #endif
  485.  
  486.  
  487. #if defined(cray) || defined(gould)
  488. #   define SLOPPYDIVIDE
  489. #endif
  490.  
  491.  
  492. #if defined(cray) || defined(convex) || defined (uts) || BYTEORDER > 0xffff
  493. #   define QUAD
  494. #endif
  495.  
  496.  
  497. #ifdef QUAD
  498. #   ifdef cray
  499. #    define quad int
  500. #   else
  501. #    if defined(convex) || defined (uts)
  502. #        define quad long long
  503. #    else
  504. #        define quad long
  505. #    endif
  506. #   endif
  507. #endif
  508.  
  509.  
  510. typedef unsigned int STRLEN;
  511.  
  512.  
  513. typedef struct arg ARG;
  514. typedef struct cmd CMD;
  515. typedef struct formcmd FCMD;
  516. typedef struct scanpat SPAT;
  517. typedef struct stio STIO;
  518. typedef struct sub SUBR;
  519. typedef struct string STR;
  520. typedef struct atbl ARRAY;
  521. typedef struct htbl HASH;
  522. typedef struct regexp REGEXP;
  523. typedef struct stabptrs STBP;
  524. typedef struct stab STAB;
  525. typedef struct callsave CSV;
  526.  
  527.  
  528. #include "handy.h"
  529. #include "regexp.h"
  530. #include "str.h"
  531. #include "util.h"
  532. #include "form.h"
  533. #include "stab.h"
  534. #include "spat.h"
  535. #include "arg.h"
  536. #include "cmd.h"
  537. #include "array.h"
  538. #include "hash.h"
  539.  
  540.  
  541. #if defined(iAPX286) || defined(M_I286) || defined(I80286)
  542. #   define I286
  543. #endif
  544.  
  545.  
  546. #ifndef    STANDARD_C
  547. #ifdef CHARSPRINTF
  548.     char *sprintf();
  549. #else
  550.     int sprintf();
  551. #endif
  552. #endif
  553.  
  554.  
  555. EXT char *Yes INIT("1");
  556. EXT char *No INIT("");
  557.  
  558.  
  559. /* "gimme" values */
  560.  
  561.  
  562. /* Note: cmd.c assumes that it can use && to produce one of these values! */
  563. #define G_SCALAR 0
  564. #define G_ARRAY 1
  565.  
  566.  
  567. #ifdef CRIPPLED_CC
  568. int str_true();
  569. #else /* !CRIPPLED_CC */
  570. #define str_true(str) (Str = (str), \
  571.     (Str->str_pok ? \
  572.         ((*Str->str_ptr > '0' || \
  573.           Str->str_cur > 1 || \
  574.           (Str->str_cur && *Str->str_ptr != '0')) ? 1 : 0) \
  575.     : \
  576.         (Str->str_nok ? (Str->str_u.str_nval != 0.0) : 0 ) ))
  577. #endif /* CRIPPLED_CC */
  578.  
  579.  
  580. #ifdef DEBUGGING
  581. #define str_peek(str) (Str = (str), \
  582.     (Str->str_pok ? \
  583.         Str->str_ptr : \
  584.         (Str->str_nok ? \
  585.         (sprintf(tokenbuf,"num(%g)",Str->str_u.str_nval), \
  586.             (char*)tokenbuf) : \
  587.         "" )))
  588. #endif
  589.  
  590.  
  591. #ifdef CRIPPLED_CC
  592. char *str_get();
  593. #else
  594. #ifdef TAINT
  595. #define str_get(str) (Str = (str), tainted |= Str->str_tainted, \
  596.     (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  597. #else
  598. #define str_get(str) (Str = (str), (Str->str_pok ? Str->str_ptr : str_2ptr(Str)))
  599. #endif /* TAINT */
  600. #endif /* CRIPPLED_CC */
  601.  
  602.  
  603. #ifdef CRIPPLED_CC
  604. double str_gnum();
  605. #else /* !CRIPPLED_CC */
  606. #ifdef TAINT
  607. #define str_gnum(str) (Str = (str), tainted |= Str->str_tainted, \
  608.     (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  609. #else /* !TAINT */
  610. #define str_gnum(str) (Str = (str), (Str->str_nok ? Str->str_u.str_nval : str_2num(Str)))
  611. #endif /* TAINT*/
  612. #endif /* CRIPPLED_CC */
  613. EXT STR *Str;
  614.  
  615.  
  616. #define GROWSTR(pp,lp,len) if (*(lp) < (len)) growstr(pp,lp,len)
  617.  
  618.  
  619. #ifndef MSDOS
  620. #define STR_GROW(str,len) if ((str)->str_len < (len)) str_grow(str,len)
  621. #define Str_Grow str_grow
  622. #else
  623. /* extra parentheses intentionally NOT placed around "len"! */
  624. #define STR_GROW(str,len) if ((str)->str_len < (unsigned long)len) \
  625.         str_grow(str,(unsigned long)len)
  626. #define Str_Grow(str,len) str_grow(str,(unsigned long)(len))
  627. #endif /* MSDOS */
  628.  
  629.  
  630. #ifndef BYTEORDER
  631. #define BYTEORDER 0x1234
  632. #endif
  633.  
  634.  
  635. #if defined(htonl) && !defined(HAS_HTONL)
  636. #define HAS_HTONL
  637. #endif
  638. #if defined(htons) && !defined(HAS_HTONS)
  639. #define HAS_HTONS
  640. #endif
  641. #if defined(ntohl) && !defined(HAS_NTOHL)
  642. #define HAS_NTOHL
  643. #endif
  644. #if defined(ntohs) && !defined(HAS_NTOHS)
  645. #define HAS_NTOHS
  646. #endif
  647. #ifndef HAS_HTONL
  648. #if (BYTEORDER & 0xffff) != 0x4321
  649. #define HAS_HTONS
  650. #define HAS_HTONL
  651. #define HAS_NTOHS
  652. #define HAS_NTOHL
  653. #define MYSWAP
  654. #define htons my_swap
  655. #define htonl my_htonl
  656. #define ntohs my_swap
  657. #define ntohl my_ntohl
  658. #endif
  659. #else
  660. #if (BYTEORDER & 0xffff) == 0x4321
  661. #undef HAS_HTONS
  662. #undef HAS_HTONL
  663. #undef HAS_NTOHS
  664. #undef HAS_NTOHL
  665. #endif
  666. #endif
  667.  
  668.  
  669. /*
  670.  * Little-endian byte order functions - 'v' for 'VAX', or 'reVerse'.
  671.  * -DWS
  672.  */
  673. #if BYTEORDER != 0x1234
  674. # define HAS_VTOHL
  675. # define HAS_VTOHS
  676. # define HAS_HTOVL
  677. # define HAS_HTOVS
  678. # if BYTEORDER == 0x4321
  679. #  define vtohl(x)    ((((x)&0xFF)<<24)    \
  680.             +(((x)>>24)&0xFF)    \
  681.             +(((x)&0x0000FF00)<<8)    \
  682.             +(((x)&0x00FF0000)>>8)    )
  683. #  define vtohs(x)    ((((x)&0xFF)<<8) + (((x)>>8)&0xFF))
  684. #  define htovl(x)    vtohl(x)
  685. #  define htovs(x)    vtohs(x)
  686. # endif
  687.     /* otherwise default to functions in util.c */
  688. #endif
  689.  
  690.  
  691. #ifdef CASTNEGFLOAT
  692. #define U_S(what) ((unsigned short)(what))
  693. #define U_I(what) ((unsigned int)(what))
  694. #define U_L(what) ((unsigned long)(what))
  695. #else
  696. unsigned long castulong();
  697. #define U_S(what) ((unsigned int)castulong(what))
  698. #define U_I(what) ((unsigned int)castulong(what))
  699. #define U_L(what) (castulong(what))
  700. #endif
  701.  
  702.  
  703. CMD *add_label();
  704. CMD *block_head();
  705. CMD *append_line();
  706. CMD *make_acmd();
  707. CMD *make_ccmd();
  708. CMD *make_icmd();
  709. CMD *invert();
  710. CMD *addcond();
  711. CMD *addloop();
  712. CMD *wopt();
  713. CMD *over();
  714.  
  715.  
  716. STAB *stabent();
  717. STAB *genstab();
  718.  
  719.  
  720. ARG *stab2arg();
  721. ARG *op_new();
  722. ARG *make_op();
  723. ARG *make_match();
  724. ARG *make_split();
  725. ARG *rcatmaybe();
  726. ARG *listish();
  727. ARG *maybelistish();
  728. ARG *localize();
  729. ARG *fixeval();
  730. ARG *jmaybe();
  731. ARG *l();
  732. ARG *fixl();
  733. ARG *mod_match();
  734. ARG *make_list();
  735. ARG *cmd_to_arg();
  736. ARG *addflags();
  737. ARG *hide_ary();
  738. ARG *cval_to_arg();
  739.  
  740.  
  741. STR *str_new();
  742. STR *stab_str();
  743.  
  744.  
  745. int do_each();
  746. int do_subr();
  747. int do_match();
  748. int do_unpack();
  749. int eval();        /* this evaluates expressions */
  750. int do_eval();        /* this evaluates eval operator */
  751. int do_assign();
  752.  
  753.  
  754. SUBR *make_sub();
  755.  
  756.  
  757. FCMD *load_format();
  758.  
  759.  
  760. char *scanpat();
  761. char *scansubst();
  762. char *scantrans();
  763. char *scanstr();
  764. char *scanident();
  765. char *str_append_till();
  766. char *str_gets();
  767. char *str_grow();
  768.  
  769.  
  770. bool do_open();
  771. bool do_close();
  772. bool do_print();
  773. bool do_aprint();
  774. bool do_exec();
  775. bool do_aexec();
  776.  
  777.  
  778. int do_subst();
  779. int cando();
  780. int ingroup();
  781.  
  782.  
  783. void str_replace();
  784. void str_inc();
  785. void str_dec();
  786. void str_free();
  787. void stab_clear();
  788. void do_join();
  789. void do_sprintf();
  790. void do_accept();
  791. void do_pipe();
  792. void do_vecset();
  793. void do_unshift();
  794. void do_execfree();
  795. void magicalize();
  796. void magicname();
  797. void savelist();
  798. void saveitem();
  799. void saveint();
  800. void savelong();
  801. void savesptr();
  802. void savehptr();
  803. void restorelist();
  804. void repeatcpy();
  805. HASH *savehash();
  806. ARRAY *saveary();
  807.  
  808.  
  809. EXT char **origargv;
  810. EXT int origargc;
  811. EXT char **origenviron;
  812. extern char **environ;
  813.  
  814.  
  815. EXT long subline INIT(0);
  816. EXT STR *subname INIT(Nullstr);
  817. EXT int arybase INIT(0);
  818.  
  819.  
  820. struct outrec {
  821.     long    o_lines;
  822.     char    *o_str;
  823.     int        o_len;
  824. };
  825.  
  826.  
  827. EXT struct outrec outrec;
  828. EXT struct outrec toprec;
  829.  
  830.  
  831. EXT STAB *stdinstab INIT(Nullstab);
  832. EXT STAB *last_in_stab INIT(Nullstab);
  833. EXT STAB *defstab INIT(Nullstab);
  834. EXT STAB *argvstab INIT(Nullstab);
  835. EXT STAB *envstab INIT(Nullstab);
  836. EXT STAB *sigstab INIT(Nullstab);
  837. EXT STAB *defoutstab INIT(Nullstab);
  838. EXT STAB *curoutstab INIT(Nullstab);
  839. EXT STAB *argvoutstab INIT(Nullstab);
  840. EXT STAB *incstab INIT(Nullstab);
  841. EXT STAB *leftstab INIT(Nullstab);
  842. EXT STAB *amperstab INIT(Nullstab);
  843. EXT STAB *rightstab INIT(Nullstab);
  844. EXT STAB *DBstab INIT(Nullstab);
  845. EXT STAB *DBline INIT(Nullstab);
  846. EXT STAB *DBsub INIT(Nullstab);
  847.  
  848.  
  849. EXT HASH *defstash;        /* main symbol table */
  850. EXT HASH *curstash;        /* symbol table for current package */
  851. EXT HASH *debstash;        /* symbol table for perldb package */
  852.  
  853.  
  854. EXT STR *curstname;        /* name of current package */
  855.  
  856.  
  857. EXT STR *freestrroot INIT(Nullstr);
  858. EXT STR *lastretstr INIT(Nullstr);
  859. EXT STR *DBsingle INIT(Nullstr);
  860. EXT STR *DBtrace INIT(Nullstr);
  861. EXT STR *DBsignal INIT(Nullstr);
  862.  
  863.  
  864. EXT int lastspbase;
  865. EXT int lastsize;
  866.  
  867.  
  868. EXT char *hexdigit INIT("0123456789abcdef0123456789ABCDEFx");
  869. EXT char *origfilename;
  870. EXT FILE * VOLATILE rsfp;
  871. EXT char buf[1024];
  872. EXT char *bufptr;
  873. EXT char *oldbufptr;
  874. EXT char *oldoldbufptr;
  875. EXT char *bufend;
  876.  
  877.  
  878. EXT STR *linestr INIT(Nullstr);
  879.  
  880.  
  881. EXT char *rs INIT("\n");
  882. EXT int rschar INIT('\n');    /* final char of rs, or 0777 if none */
  883. EXT int rslen INIT(1);
  884. EXT char *ofs INIT(Nullch);
  885. EXT int ofslen INIT(0);
  886. EXT char *ors INIT(Nullch);
  887. EXT int orslen INIT(0);
  888. EXT char *ofmt INIT(Nullch);
  889. EXT char *inplace INIT(Nullch);
  890. EXT char *nointrp INIT("");
  891.  
  892.  
  893. EXT bool preprocess INIT(FALSE);
  894. EXT bool minus_n INIT(FALSE);
  895. EXT bool minus_p INIT(FALSE);
  896. EXT bool minus_l INIT(FALSE);
  897. EXT bool minus_a INIT(FALSE);
  898. EXT bool doswitches INIT(FALSE);
  899. EXT bool dowarn INIT(FALSE);
  900. EXT bool doextract INIT(FALSE);
  901. EXT bool allstabs INIT(FALSE);    /* init all customary symbols in symbol table?*/
  902. EXT bool sawampersand INIT(FALSE);    /* must save all match strings */
  903. EXT bool sawstudy INIT(FALSE);        /* do fbminstr on all strings */
  904. EXT bool sawi INIT(FALSE);        /* study must assume case insensitive */
  905. EXT bool sawvec INIT(FALSE);
  906. EXT bool localizing INIT(FALSE);    /* are we processing a local() list? */
  907.  
  908.  
  909. #ifndef MAXSYSFD
  910. #   define MAXSYSFD 2
  911. #endif
  912. EXT int maxsysfd INIT(MAXSYSFD);    /* top fd to pass to subprocesses */
  913.  
  914.  
  915. #ifdef CSH
  916. char *cshname INIT(CSH);
  917. int cshlen INIT(0);
  918. #endif /* CSH */
  919.  
  920.  
  921. #ifdef TAINT
  922. EXT bool tainted INIT(FALSE);        /* using variables controlled by $< */
  923. #endif
  924.  
  925.  
  926. #ifndef MSDOS
  927. #define TMPPATH "/tmp/perl-eXXXXXX"
  928. #else
  929. #define TMPPATH "plXXXXXX"
  930. #endif /* MSDOS */
  931. EXT char *e_tmpname;
  932. EXT FILE *e_fp INIT(Nullfp);
  933.  
  934.  
  935. EXT char tokenbuf[256];
  936. EXT int expectterm INIT(TRUE);        /* how to interpret ambiguous tokens */
  937. EXT VOLATILE int in_eval INIT(FALSE);    /* trap fatal errors? */
  938. EXT int multiline INIT(0);        /* $*--do strings hold >1 line? */
  939. EXT int forkprocess;            /* so do_open |- can return proc# */
  940. EXT int do_undump INIT(0);        /* -u or dump seen? */
  941. EXT int error_count INIT(0);        /* how many errors so far, max 10 */
  942. EXT int multi_start INIT(0);        /* 1st line of multi-line string */
  943. EXT int multi_end INIT(0);        /* last line of multi-line string */
  944. EXT int multi_open INIT(0);        /* delimiter of said string */
  945. EXT int multi_close INIT(0);        /* delimiter of said string */
  946.  
  947.  
  948. FILE *popen();
  949. /* char *str_get(); */
  950. STR *interp();
  951. void free_arg();
  952. STIO *stio_new();
  953. void hoistmust();
  954. void scanconst();
  955.  
  956.  
  957. EXT struct stat statbuf;
  958. EXT struct stat statcache;
  959. EXT STAB *statstab;
  960. EXT STR *statname;
  961. #ifndef MSDOS
  962. EXT struct tms timesbuf;
  963. #endif
  964. EXT int uid;
  965. EXT int euid;
  966. EXT int gid;
  967. EXT int egid;
  968. UIDTYPE getuid();
  969. UIDTYPE geteuid();
  970. GIDTYPE getgid();
  971. GIDTYPE getegid();
  972. EXT int unsafe;
  973.  
  974.  
  975. #ifdef DEBUGGING
  976. EXT VOLATILE int debug INIT(0);
  977. EXT int dlevel INIT(0);
  978. EXT int dlmax INIT(128);
  979. EXT char *debname;
  980. EXT char *debdelim;
  981. #define YYDEBUG 1
  982. #endif
  983. EXT int perldb INIT(0);
  984. #define YYMAXDEPTH 300
  985.  
  986.  
  987. EXT line_t cmdline INIT(NOLINE);
  988.  
  989.  
  990. EXT STR str_undef;
  991. EXT STR str_no;
  992. EXT STR str_yes;
  993.  
  994.  
  995. /* runtime control stuff */
  996.  
  997.  
  998. EXT struct loop {
  999.     char *loop_label;        /* what the loop was called, if anything */
  1000.     int loop_sp;        /* stack pointer to copy stuff down to */
  1001.     jmp_buf loop_env;
  1002. } *loop_stack;
  1003.  
  1004.  
  1005. EXT int loop_ptr INIT(-1);
  1006. EXT int loop_max INIT(128);
  1007.  
  1008.  
  1009. EXT jmp_buf top_env;
  1010.  
  1011.  
  1012. EXT char * VOLATILE goto_targ INIT(Nullch); /* cmd_exec gets strange when set */
  1013.  
  1014.  
  1015. struct ufuncs {
  1016.     int (*uf_val)();
  1017.     int (*uf_set)();
  1018.     int uf_index;
  1019. };
  1020.  
  1021.  
  1022. EXT ARRAY *stack;        /* THE STACK */
  1023.  
  1024.  
  1025. EXT ARRAY * VOLATILE savestack;        /* to save non-local values on */
  1026.  
  1027.  
  1028. EXT ARRAY *tosave;        /* strings to save on recursive subroutine */
  1029.  
  1030.  
  1031. EXT ARRAY *lineary;        /* lines of script for debugger */
  1032. EXT ARRAY *dbargs;        /* args to call listed by caller function */
  1033.  
  1034.  
  1035. EXT ARRAY *fdpid;        /* keep fd-to-pid mappings for mypopen */
  1036. EXT HASH *pidstatus;        /* keep pid-to-status mappings for waitpid */
  1037.  
  1038.  
  1039. EXT int *di;            /* for tmp use in debuggers */
  1040. EXT char *dc;
  1041. EXT short *ds;
  1042.  
  1043.  
  1044. /* Fix these up for __STDC__ */
  1045. EXT long basetime INIT(0);
  1046. char *mktemp();
  1047. #ifndef STANDARD_C
  1048. /* All of these are in stdlib.h or time.h for ANSI C */
  1049. double atof();
  1050. long time();
  1051. struct tm *gmtime(), *localtime();
  1052. char *index(), *rindex();
  1053. char *strcpy(), *strcat();
  1054. #endif /* ! STANDARD_C */
  1055.  
  1056.  
  1057. #ifdef EUNICE
  1058. #define UNLINK unlnk
  1059. int unlnk();
  1060. #else
  1061. #define UNLINK unlink
  1062. #endif
  1063.  
  1064.  
  1065. #ifndef HAS_SETREUID
  1066. #ifdef HAS_SETRESUID
  1067. #define setreuid(r,e) setresuid(r,e,-1)
  1068. #define HAS_SETREUID
  1069. #endif
  1070. #endif
  1071. #ifndef HAS_SETREGID
  1072. #ifdef HAS_SETRESGID
  1073. #define setregid(r,e) setresgid(r,e,-1)
  1074. #define HAS_SETREGID
  1075. #endif
  1076. #endif
  1077.